<?php
/**
 * Created by PhpStorm.
 * User: DaveTang
 * Date: 2020/2/24
 * Time: 13:56
 */

namespace App\Controller\Component;
use Cake\Controller\Component;
use Cake\Cache\Cache;

class CacheTimeComponent extends Component
{

    public function getTime()
    {
        $time = Cache::read('cachetime', 'r5y');
        if(empty($time)){
            $time = time();
            Cache::write('cachetime', $time, 'r5y');
        }
        return $time;
    }

    public function setTime() {
        $time = time();
        Cache::write('cachetime', $time, 'r5y');
    }


}